//
//  EntrepreneurDetailView.m
//  BigToBig
//
//  Created by liuyi on 7/19/16.
//  Copyright © 2016 cn.cloudtp. All rights reserved.
//

#import "EntrepreneurDetailView.h"
#import "HomeProjectMarkCell.h"

@interface EntrepreneurDetailView ()
<
    UICollectionViewDelegate,
    UICollectionViewDataSource
>


@end

@implementation EntrepreneurDetailView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/


- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews{
    self.backgroundColor = [UIColor whiteColor];
    
//  头像
    self.headImageView = [[UIImageView alloc]initWithFrame:CGRectMake(10, 10, (kScreenWidth - 20)/6, (kScreenWidth - 20)/6)];
    self.headImageView.center = CGPointMake(self.headImageView.width / 2 + 10, 50);
    self.headImageView.image = [UIImage imageNamed:@"touxiang"];
    [self addSubview:self.headImageView];
    self.headImageView.layer.cornerRadius = (kScreenWidth - 20)/12;
    self.headImageView.layer.masksToBounds = YES;
//评分
    self.score = [[UILabel alloc] initWithFrame:CGRectMake(kScreenWidth - 100, 20, 80, 20)];
    self.score.text = @"评分 : 9";
    self.score.font = [UIFont systemFontOfSize:13];
    self.score.textColor = [UIColor redColor];
    self.score.textAlignment = NSTextAlignmentRight;
    [self addSubview:self.score];

// 标题
    self.titleLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.headImageView.maxX + 10, self.headImageView.y, kScreenWidth - self.headImageView.maxX - 10, self.headImageView.height /3)];
    [self addSubview:self.titleLabel];
    self.titleLabel.textAlignment = NSTextAlignmentLeft;
    
// 标签
    UICollectionViewFlowLayout *markLayout = [[UICollectionViewFlowLayout alloc]init];
    markLayout.itemSize = CGSizeMake(self.titleLabel.width / 5 , self.titleLabel.height);
    markLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    markLayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 5);
    self.markCollectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(self.titleLabel.x, self.titleLabel.maxY, self.titleLabel.width, self.titleLabel.height) collectionViewLayout:markLayout];
    self.markCollectionView.delegate = self;
    self.markCollectionView.dataSource = self;
    self.markCollectionView.backgroundColor = [UIColor whiteColor];
    self.markCollectionView.showsHorizontalScrollIndicator = false;
    [self.markCollectionView registerClass:[HomeProjectMarkCell class] forCellWithReuseIdentifier:NSStringFromClass([HomeProjectMarkCell class])];
    [self addSubview:self.markCollectionView];
    
    // 分类名
    self.groupLabel = [[UILabel alloc]initWithFrame:CGRectMake(self.markCollectionView.x, self.markCollectionView.maxY + 2, self.headImageView.width + 10, self.titleLabel.height)];
    _groupLabel.backgroundColor = COLOR_RGBA(0, 228, 161, 1);
    _groupLabel.font = [UIFont systemFontOfSize:12];
    _groupLabel.textAlignment = 1;
    _groupLabel.textColor = [UIColor whiteColor];
    _groupLabel.layer.cornerRadius = 5;
    _groupLabel.layer.masksToBounds = YES;
    [self addSubview:_groupLabel];
    
    // 已关注图标
    UIImageView *focusImageView = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenWidth / 9 * 5, _groupLabel.y, self.headImageView.width / 7 * 2, self.headImageView.width / 7 * 2)];
    focusImageView.image = [UIImage imageNamed:@"guanzhu"];
    [self addSubview:focusImageView];
    
    // 已关注人数
    self.focusLabel = [[UILabel alloc]initWithFrame:CGRectMake(focusImageView.maxX, focusImageView.y, kScreenWidth / 9 * 2 - focusImageView.width, focusImageView.height)];
    self.focusLabel.font = [UIFont systemFontOfSize:10];
    self.focusLabel.text = @"  已关注 :0";
    self.focusLabel.textColor = [UIColor lightGrayColor];
    [self addSubview:self.focusLabel];
    
    // 已查看图标
    UIImageView *funsImageView = [[UIImageView alloc]initWithFrame:CGRectMake(kScreenWidth / 9 * 7, _groupLabel.y, focusImageView.width, focusImageView.height)];
    funsImageView.image = [UIImage imageNamed:@"fensi"];
    [self addSubview:funsImageView];
    
    // 已查看人数
    self.funsLabel = [[UILabel alloc]initWithFrame:CGRectMake(funsImageView.maxX, funsImageView.y, self.focusLabel.width , self.focusLabel.height)];
    self.funsLabel.font = [UIFont systemFontOfSize:10];
    self.funsLabel.text = @"  粉丝 :0";
    self.funsLabel.textColor = [UIColor lightGrayColor];
    [self addSubview:self.funsLabel];
    

    


}

#pragma mark - markCollectionView 代理方法

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{
    return self.markArray.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    HomeProjectMarkCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([HomeProjectMarkCell class]) forIndexPath:indexPath];
    cell.markContent = self.markArray[indexPath.row];
    
    return cell;
    
}




@end
